package org.lcx.pipeline.example.submitorder;

import org.lcx.pipeline.Processor;
import org.lcx.pipeline.bean.PipelineExeption;
import org.lcx.pipeline.bean.PipelineResult;

import java.util.Map;
import java.util.Random;

/**
 * 公交车
 */
public class DistanceProcessor implements Processor {

    @Override
    public int runProcess(Object params, PipelineResult result) throws PipelineExeption {
        int resultint = 0;

        StringBuffer msgFormat = new StringBuffer("距离逻辑");
        Random random = new Random();
        int randomNum = random.nextInt(10);
        msgFormat.append("-->开始处理, 处理的结果：" + randomNum);


        Map paramMap = (Map) params;

        // resultint 表示对下一步的选择
        resultint = (int)paramMap.get("distanceNext") ;

        paramMap.put("distanceResult",randomNum);

        Object speedResult = paramMap.get("speedResult");
        System.out.println("-------> 在距离步骤，拿到的速度结果：" + speedResult);

        System.out.println(msgFormat.toString());
        return resultint;
    }

}
